package com.zzt.zt_hilt.entity

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import javax.inject.Qualifier

/**
 * @author: zeting
 * @date: 2022/8/29
 *
 */
//还是一样的模式，定义一个模块
@Module
@InstallIn(ActivityComponent::class)
object CompanyModule {
    //使用@Provides注解
    @Provides
    fun provideCompany(): Company {
        //不是抽象函数了，有具体的函数体
        return CompanyInfo.getCompany()
    }

}

//接口，假如是外部库的
interface Company {
    fun getCompany(): String
}

//接口实现
class HighTech() : Company {
    override fun getCompany(): String {
        return "腾讯"
    }
}

//假设自己项目中的代码
object CompanyInfo {
    fun getCompany(): Company {
        val highTech = HighTech()
        return highTech
    }
}
